using Microsoft.AspNetCore.Mvc;
using Vin.AspNetCore.Core.Controller;
using Vin.Extension.Quartz.Models;
using Vin.Extension.Quartz.Service;
using Vin.Framework.Api.Tests.Jobs;
using Vin.Tool.Attributes;

namespace Vin.Framework.Api.Tests.Controllers;

[Route("job")]
public class TestJobController : VinBaseController
{
    [Inject] private readonly VinTaskService _taskService = null!;

    [HttpGet("add")]
    public async Task<IActionResult> Add()
    {
        var param = new Dictionary<string, object>
        {
            { "test", "123456" },
            { "Obj", new { a = 0 } }
        };
        await _taskService.AddJobTask<TestJob>(new TaskInfo("test", "测试", "group", param)
        {
            StartTime = DateTime.Now.AddSeconds(5)
        });
        return Success();
    }
    
    [HttpGet("remove")]
    public async Task<IActionResult> Remove()
    {
        await _taskService.PauseJobTask("test", "group");
        // await _taskService.RemoveJobTask("test", "group");
        return Success();
    }
}